function [htoolbar, haudiobtns] = render_fullaudiotoolbar(h)
%RENDER_FULLAUDIOTOOLBAR Create complete audio toolbar.
%   [HTOOLBAR, HBUTTONS] = RENDER_FULLAUDIOTOOLBAR(HFIG) creates a new
%   toolbar with go to start, rewind, record, play, pause, stop, fast
%   forward, and go to end buttons that will operate on an audioplayer
%   and an audiorecorder object.  A new toolbar will be added to the
%   figure HFIG. Handles to the new toolbar and array of pushbuttons
%   are returned.
%
%   RENDER_FULLAUDIOTOOLBAR(HTOOLBAR) adds the audio buttons in
%   sequence to toolbar HTOOLBAR.

%   Author(s): B. Wherry
%   Copyright 1984-2004 The MathWorks, Inc.
%   $Revision: 1.1.6.2 $  $Date: 2007/12/14 15:03:32 $

error(nargchk(1,1,nargin,'struct'));

hType = get(h, 'Type');
% if h is the handle to a figure, add a new toolbar to it
if strcmp(hType, 'figure'),
    htoolbar = uitoolbar(h);
    set(htoolbar, 'Tag', 'FullAudioToolbar');
% if h is the handle to a toolbar, add our toolbar buttons to it
elseif strcmp(hType, 'uitoolbar'),
    htoolbar = h;
% if h is something else, error
else
    error(generatemsgid('GUIErr'),'This function only accepts handles to figures and uitoolbars.');
end

% Load audio icons
icons = load('audiotoolbaricons');

% stick all the icons into app data for swapping in/out, etc.
setappdata(htoolbar, 'audioButtonIcons', icons);

pushbtns = {icons.goto_start_default,...
            icons.rewind_default,...
            icons.record_off,...
            icons.play_off,...
            icons.pause_default,...
            icons.stop_default,...
            icons.ffwd_default,...
            icons.goto_end_default};

tooltips = {'Go to beginning',...
            'Rewind',...
            'Record',...
            'Play',...
            'Pause',...
            'Stop',...
            'Fast forward',...
            'Go to end'};

tags = {'goto_beg',...
        'rewind',...
        'record',...
        'play',...
        'pause',...
        'stop',...
        'ffwd',...
        'goto_end'};

sep = {'On','Off','Off','Off','Off','Off','Off','Off'};

fcns = menus_cbs;

btncbs = {fcns.gtbeg_cb,...
          fcns.rewind_cb,...
          fcns.record_cb,...
          fcns.play_cb,...
          fcns.pause_cb,...
          fcns.stop_cb,...
          fcns.ffwd_cb,...
          fcns.gtend_cb};

% Render the PushButtons
for i = 1:length(pushbtns),
   haudiobtns(i) = uipushtool('Cdata',pushbtns{i},...
        'Parent', htoolbar,...
        'ClickedCallback',btncbs{i},...
        'Tag',            tags{i},...
        'Separator',      sep{i},...
        'Tooltipstring',  tooltips{i});
end
